package org.lanqiao.api.admin;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.pojo.PageModel;
import org.lanqiao.service.AdminServiceImpl;

/**
 * 删除指定ID类别
 * Servlet implementation class DeleteCategoryServlet
 */
@WebServlet("/api/admin/DeleteCategoryServlet")
public class DeleteCategoryServlet extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{	
		String id=request.getParameter("categoryId");
		/**
		 * 调用查询类别
		 */
		AdminServiceImpl abc=new AdminServiceImpl();
		JsonResult result=null;
		try {
			int model=abc.deleteCategory(id);
			if(model>0){
				result=new JsonResult("删除成功",Constants.STATUS_SUCCESS);
			}else {
				result=new JsonResult("删除错误",Constants.STATUS_UNFOUND);
			}
		} catch (Exception e) {
			result=new JsonResult("删除异常",Constants.STATUS_FAILURE);
		}
		JsonResultWriter.writer(response, result);
	}

}
